package com.example.liquortest;
import okhttp3.Headers;
import okhttp3.Request;

import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class Test {
    public static void main(String[] args) {
        //该参数为运行时注入，此处为模拟
        Request.Builder requestBuilder = new Request.Builder();
        Map<String, String> headers = new HashMap<>();
        headers.put("x-ca-key","26606678");
        headers.put("x-ca-nonce",UUID.randomUUID().toString());
        headers.put("x-ca-timestamp",String.valueOf(new Date().getTime()));
        headers.put("x-ca-signature-headers","x-ca-key,x-ca-nonce,x-ca-timestamp");
        headers.forEach((k, v) -> {
            if (v != null) {
                headers.put(k, new String(v.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));
            }
        });
        requestBuilder.headers(Headers.of(headers));
    }
}
